import request from '@/utils/request'

// 新闻分类保存
export const saveNewsCategory = (data) => {
  return request({
    url: '/api/admin/saveNewsCategory',
    method: 'post',
    data
  })
}

// 获取新闻分类列表
export const getNewsCategoryList = (params) => {
  return request({
    url: '/api/admin/getNewsCategorys',
    method: 'get',
    params
  })
}

// 新闻文章保存
export const saveNews = (data) => {
  return request({
    url: '/api/admin/saveNews',
    method: 'post',
    data
  })
}

// 获取新闻列表-分页
export const getNewsList = (data) => {
  return request({
    url: '/api/admin/getNewsPage',
    method: 'post',
    data
  })
}

// 获取新闻详情
export const getNewsDetail = (params) => {
  return request({
    url: '/api/admin/getNews',
    method: 'get',
    params
  })
}

export const setDeleteNews = (params) => {
  return request({
    url: '/api/admin/setDeleteNews',
    method: 'post',
    params
  })
}

// 获取新闻评论（可根据标题模糊匹配，或分类匹配）
export const getNewsComments = (data) => {
  return request({
    url: '/api/admin/getNewsCommentPage',
    method: 'post',
    data
  })
}

// 新闻评论删除设置
export const deleteNewsComment = (params) => {
  return request({
    url: '/api/admin/setDelNewsComment',
    method: 'post',
    params
  })
}

// 保存产品信息和图片地址
export const saveProduct = (data) => {
  return request({
    url: '/api/admin/saveProds',
    method: 'post',
    data
  })
}

// 获取产品列表
export const getProductList = (data) => {
  return request({
    url: '/api/admin/getProdPage',
    method: 'post',
    data
  })
}

// 获取产品详情
export const getProductDetail = (params) => {
  return request({
    url: '/api/admin/getProd',
    method: 'get',
    params
  })
}

// 产品下架操作
export const setProductDown = (data) => {
  return request({
    url: '/api/admin/setDelProd',
    method: 'post',
    data
  })
}

// 登记列表-分页
export const getRegisterList = (data) => {
  return request({
    url: '/api/admin/getRegisPage',
    method: 'post',
    data
  })
}

// 登记详情
export const getRegisterDetail = (params) => {
  return request({
    url: '/api/admin/getRegis',
    method: 'get',
    params
  })
}

// 会员后台列表查询-分页
export const getMemberList = (data) => {
  return request({
    url: '/api/admin/getMemberPage',
    method: 'post',
    data
  })
}

// 后台查看会员详情
export const getMemberDetail = (params) => {
  return request({
    url: '/api/admin/getMember',
    method: 'get',
    params
  })
}

// 上传图片
export const uploadImg = (data) => {
  return request({
    url: '/api/admin/upload',
    method: 'post',
    headers: {
      'Content-Type': 'application/x-www-form-urlencoded; charset=UTF-8'
    },
    data
  })
}

// 管理员登录
export const login = (params) => {
  return request({
    url: '/api/admin/login',
    method: 'post',
    params
  })
}

// 管理员新增
export const addAdmin = (data) => {
  return request({
    url: '/api/admin/save',
    method: 'post',
    data
  })
}

// 管理员列表-分页
export const getAdminList = (data) => {
  return request({
    url: '/api/admin/adminList',
    method: 'post',
    data
  })
}

// 管理员详情
export const getAdminDetail = (params) => {
  return request({
    url: '/api/admin/getAdmin',
    method: 'get',
    params
  })
}